package com.sky.controller.information;

import com.sky.dto.CustomerDTO;
import com.sky.result.Result;
import com.sky.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;

@RestController
@RequestMapping("/information")
public class InformationController {
    @Autowired
    private InformationService informationService;

    /**
     * 新增车辆信息
     * @param customerDTO
     * @return
     */

    @RequestMapping("/add")
    public Result<Object> add(@RequestBody CustomerDTO customerDTO){
        informationService.addCarInformation(customerDTO);
        return Result.successT("添加成功");
    }

    /**
     * 修改
     * @param customerDTO
     * @return
     */
    @RequestMapping("/edit")
    public Result<Object> edit(@RequestBody CustomerDTO customerDTO){
        informationService.editCarInformation(customerDTO);
        return Result.successT("修改成功");
    }

    @RequestMapping("/delete")
    public Result<Object> delete(@PathParam("customerId") Long customerId){
        informationService.deleteCarInformation(customerId);
        return Result.successT("删除成功");
    }
}
